//
//  Packet.m
//  EasyTip
//
//  Created by Jeffrey Palm on 2/14/09.
//  Copyright 2009 Jeffrey Palm. All rights reserved.
//

#import "Packet.h"
#import "Category.h"


@implementation Packet

@synthesize pid;
@synthesize categories;
@synthesize firstCategory;

- (id)initWithName:(NSString*)theName pid:(NSString*)thePid {
	if (self = [super initWithName:theName]) {
		self.pid = thePid;
		self.categories = [NSMutableArray array];
	}
	return self;
}

- (void) add:(Category*)cat {
	[categories addObject:cat];
	if (lastCategory  ) lastCategory.next = cat;
	if (!firstCategory) firstCategory     = cat;
	lastCategory = cat;
}

- (void) dealloc {
	[lastCategory release];
	[firstCategory release];
	[self.categories release];
	[super dealloc];
}

@end
